package com.shop.shopserver.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.shop.shoppojo.entity.Goods;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Update;

@Mapper
public interface StockTotalMapper extends BaseMapper<Goods> {
    /**
     * 更新商品库存和销量
     * @param goodsId
     * @param goodsNum
     */
    @Update("update goods set stock_total = stock_total - #{goodsNum},goods_sales = goods_sales + #{goodsNum} where id = #{goodsId}")
    void updataStockAndSales(Long goodsId, Integer goodsNum);
}
